<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var persons = [
        {
          username: '张飞',
          sex: '男',
          salary: 50000,
        },
        {
          username: '关羽',
          sex: '男',
          salary: 60000,
        },
      ];
      var persons1 = persons.map(function (item, index, array) {
        return {
          username: item.username,
          sex: item.sex,
          salary: item.salary + 2000,
        };
      });
      console.log(persons1);
      console.log(persons);
      //------------------------------------------------------------------
      //   var arr1 = [...persons];
      //   console.log(arr1);
      //   for (var i = 0; i < arr1.length; i++) {
      //     arr1[i].salary = arr1[i].salary + 2000;
      //   }
      //   console.log(arr1);
      //--------------------------------------------------------
      //   arr1.forEach(function (item, index, array) {
      //     item.salary = item.salary + 2000;
      //   });
      //   console.log(arr1);
    </script>
  </body>
</html>
